package com.whiteblue.validator;

import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;

/**
 * Created by WhiteBlue on 15/4/5.
 */
public class AddBookValidator extends Validator {
    @Override
    protected void validate(Controller controller) {
        this.validateString("ISBN",true,1,30,"msg","ISBN有误");
        this.validateInteger("type",0,2,"msg","输入错误");
        this.validateInteger("category",1,50,"msg","输入错误");
        this.validateString("method",false, 0, 100, "msg", "条件有误");
        this.validateString("contact",true, 1, 100, "msg", "请输入联系方式");
    }

    @Override
    protected void handleError(Controller controller) {
        controller.render("/info.html");
    }
}
